Creating a Horizontal Rule in HTML Paragraph

In HTML, you can create a horizontal rule by using the <hr> tag. With the use of <hr> tag, You can actually create a horizontal line on a Web page. The purpose of the <hr> tag is to separate paragraphs or sections on a Web page. This tag is useful for long documents, which the web browser presents as a single page, to separate blocks of text in the document. The web browser starts a horizontal rule from a new line, and any text that follows this tag is also displayed in a new line. Below given briefly describes the attributes of the <hr> tag:

Attributes

Description

align

Aligns a horizontal rule on a Web page.

<hr align=”left”> aligns a horizontal rule to the left of a Web page.

<hr align=”right” aligns a horizontal rule to the right of a Web page.

<hr align=”center”> aligns a horizontal rule to the center of a Web page this is the default alignment.

size

Changes the size of horizontal rule.

width

Sets the width of a horizontal rule. It can be set to a fixed number of pixels, or to a percentage of a web page.

Let’s do the following steps to create a horizontal rule: open  a blank document in Notepad and add the code:


<!DOCTYPE html>
<head>
<title>Creating  horizontal rule </title>
</head>
<body>
    <p>The hr elment in HTML defines a horizontal rule: </p>
    <hr>
    <p> This is an example of hr tag with left lignment.</p>
    <hr align=”left” width=”70%”>
    <p> This is an example of hr tag with center lignment.</p>
    <hr align=”center” width=”90%”>
    <p> This is an example of hr tag with right lignment.</p>
    <hr align=”right” width=”60%”>
    <p> This is an example of hr tag with size 30.</p>
    <hr align=”center” width=”30”>

</body>
</html> 

Save  the document with the name of CreatingHorizontalrule.html. Open the HTML document in browser, it look like this:

The hr elment in HTML defines a horizontal rule:


This is an example of hr tag with left lignment.


This is an example of hr tag with center lignment.


This is an example of hr tag with right lignment.


This is an example of hr tag with size 30.